<template>
  <div class="news_detalis">
    <!-- 标题 -->
    <h1>{{newsInfo.title}}</h1>
    <!-- 介绍 -->
    <div class="introd">
      <span>{{category.name}}</span> -
      <span>{{newsInfo.create_at}}</span>
      <span>浏览量：{{newsInfo.watch_num}}</span>
    </div>
    <div class="new_detail">
      <div v-html="newsInfo.content"></div>
    </div>
  </div>
</template>

<script>
import { getArticleDetail } from "../api/newDetails";
export default {
  name: "NewsDetails",
  data () {
    return {
      newsInfo: "",
      category: ''
    };
  },
  methods: {
    getArticleDetail (id) {
      let that = this;
      getArticleDetail(id).then((res) => {
        if (res.code == 200) {
          that.newsInfo = res.data;
          that.category = res.data.category
        } 
      });
    },
  },
  updated () { },
  mounted () {
    this.getArticleDetail(this.$route.query.id);
  },
};
</script>

<style lang="less">
.news_detalis {
  padding: 10px;
  h1 {
    font-size: 20px;
    font-weight: 700;
    line-height: 30px;
    padding: 10px 0;
  }
  .introd {
    color: #666;
    & span:last-child {
      float: right;
    }
  }
  .new_detail {
    margin-top: 20px;
    img {
      margin: 5px 0;
      width: 100% !important;
    }
  }
}
</style>